<template>
    <div class="song_sheet">
        <div class="card">
            <div class="song_top">
                <img class="bcg" :src="shogVal.coverImgUrl" alt="" />
                <div class="left">
                    <img :src="shogVal.coverImgUrl" alt="tupie" />
                </div>
                <div class="right">
                    <span class="a"
                        ><i class="iconfont icon-good"></i> 精品歌单</span
                    >
                    <p class="b">{{ shogVal.name }}</p>
                </div>
            </div>
            <div class="song_bottom">
                <div class="song_leixing">
                    <div class="left">
                        <span
                            >{{ playListPrams.cat }}
                            <i class="iconfont icon-arrow-right-bold"></i
                        ></span>
                    </div>
                    <div class="right">
                        <p
                            v-for="(item, index) in tags"
                            :class="playListPrams.cat == item.name ? 'active' : ''"
                            :key="index"
                            @click="tagClick(item.name)"
                        >
                            {{ item.name }}
                        </p>
                    </div>
                </div>
                <div class="song_card">
                    <div
                        class="song_sheet_card"
                        v-for="item in playlist"
                        :key="item.id"
                        @click="toMusiclistdetail(item.id)"
                    >
                        <img :src="item.coverImgUrl" alt="" />
                        <p>{{ item.name }}</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import request from "@/request/request.js";
export default {
    data() {
        return {
            shogVal: {},
            tags: [],
            playlist: [],
            playListPrams: {
                cat: "华语",
                offset: 50
            }
        };
    },
    methods: {
        tagClick(name) {
            this.playListPrams.cat = name;
            this.getPlayList(name);
        },
        getPlayList(tagName) {
            request(
                `/top/playlist?cat=${
                    tagName && this.playListPrams.cat
                }&offset=${this.playListPrams.offset}`
            ).then(res => {
                console.log(res);
                this.playlist = res.data.playlists;
            });
        },
        toMusiclistdetail(id) {
            this.$router.push(`/musiclistdetail/${id}`);
        }
    },
    created() {
        request("/top/playlist/highquality?limit=1").then(res => {
            this.shogVal = res.data.playlists[0];
        });
        request("/playlist/hot").then(res => {
            this.tags = res.data.tags;
        });
        this.getPlayList();
    }
};
</script>

<style lang="less" scoped>
.song_sheet {
    background-color: rgb(255, 255, 255);
    width: 100%;
    display: flex;
    justify-content: center;
    .card {
        width: 1000px;
        padding-top: 50px;
        .song_top {
            display: flex;
            padding: 12px;
            align-items: center;
            position: relative;
            border-radius: 15px;
            z-index: 3;
            overflow: hidden;
            &::before {
                content: "";
                position: absolute;
                top: 500;
                left: 0;
                width: 100%;
                height: 100%;
                background-color: #686868ee;
                filter: blur(100px);
            }
            .bcg {
                position: absolute; // 设置据对定位
                width: 100%; // 背景宽度为100%
                left: -2px; // 距离左边为-2个像素  就是整个图片向左移动了2个像素
                top: -100px; // 距离顶部是-100个像素 整个图片向上移动了100个像素
                z-index: -1; // 向下移动一层
                filter: blur(20px); // 设置滤镜
            }
            .left {
                display: flex;
                align-items: center;
                z-index: 2;
                img {
                    width: 150px;
                    height: 150px;
                    border-radius: 15px;
                }
            }
            .right {
                z-index: 2;
                margin-top: -40px;
                .a {
                    border-radius: 50px;
                    border: 1px solid #ffd88f;
                    color: #ffd483;
                    padding: 5px 10px;
                    margin-left: 30px;
                    font-weight: 700;
                }
                .b {
                    color: #fff;
                    font-size: 16px;
                    margin: 20px;
                    font-weight: 700;
                }
            }
        }

        .song_bottom {
            .song_leixing {
                display: flex;
                justify-content: space-between;
                padding: 20px 0;
                align-items: center;
                .left {
                    border-radius: 30px;
                    border: 1px solid #a7a7a6;
                    padding: 5px 10px;
                    span {
                        color: black;
                        display: flex;
                        align-items: center;
                        font-size: 15px;
                        i {
                            font-size: 15px;
                        }
                    }
                }
                .right {
                    display: flex;
                    align-items: center;
                    div {
                        display: flex;
                        align-items: center;
                    }
                    p {
                        font-size: 15px;
                        padding: 2px 10px;
                        cursor: pointer;
                    }
                    .active {
                        color: #f97855;
                        font-weight: 700;
                        background-color: #ffd4c9;
                        border: 1px solid #ffc3b3;
                        border-radius: 20px;
                    }
                }
            }

            .song_card {
                display: flex;
                flex-wrap: wrap;
                justify-content: space-between;
                padding: 5px 0 90px;
                .song_sheet_card {
                    border-radius: 20px;
                    text-align: start;
                    cursor: pointer;
                    width: 18%;
                    height: 18%;
                    box-sizing: border-box;
                    padding-bottom: 20px;
                    img {
                        border-radius: 10px;
                        width: 100%;
                        height: 100%;
                    }
                    p {
                        font-size: 16px;
                        font-weight: 700;
                    }
                }
            }
        }
    }
}
</style>
